package org.eclipse.football;

import java.util.ArrayList;

public class Team {
	// Define private member variables
	private String name;
	private ArrayList<OffPlayer> off_players = new ArrayList<OffPlayer>();
	private ArrayList<DefPlayer> def_players = new ArrayList<DefPlayer>();
	private ArrayList<Kicker> kickers = new ArrayList<Kicker>();
	
	// Define constructor
	public Team(String name){
		// Set the member variables to be the value of the input variables
		this.name = name;
	}
	
	// Getters and Setters
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<OffPlayer> getOff_players() {
		return off_players;
	}

	public void setOff_players(ArrayList<OffPlayer> off_players) {
		this.off_players = off_players;
	}

	public ArrayList<DefPlayer> getDef_players() {
		return def_players;
	}

	public void setDef_players(ArrayList<DefPlayer> def_players) {
		this.def_players = def_players;
	}

	public ArrayList<Kicker> getKickers() {
		return kickers;
	}

	public void setKickers(ArrayList<Kicker> kickers) {
		this.kickers = kickers;
	}

	// Define function to add an offensive player
	public void addOffPlayer(OffPlayer player){
		// Add player to off_players array
		off_players.add(player);
	}
	
	// Define a function to add a defensive player
	public void addDefPlayer(DefPlayer player){
		// Add player to def_players array
		def_players.add(player);
	}
	
	// Define a function to add a kicker
	public void addKicker(Kicker player){
		// Add player to kickers array
		kickers.add(player);
	}
	
	// Define a function to find an offensive player by name
	public OffPlayer findOffPlayer(String name){
		// Initialize a null player
		OffPlayer player = null;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Check if this players name matches input name
			if(off_players.get(i).getName().equals(name)){
				// If so then make player this player
				player = off_players.get(i);
			}
		}
		
		// Return player
		return player;
	}
	
	// Define a function to find a defensive player by name
	public DefPlayer findDefPlayer(String name){
		// Initialize a null player
		DefPlayer player = null;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Check if this players name matches input name
			if(def_players.get(i).getName().equals(name)){
				// If so then make player this player
				player = def_players.get(i);
			}
		}
		
		// return player
		return player;
	}
	
	// Define a function to find a kicker by name
	public Kicker findKicker(String name){
		// Initialize a null player
		Kicker player = null;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Check if this kickers name matches input name
			if(kickers.get(i).getName().equals(name)){
				// If so then make player this kicker
				player = kickers.get(i);
			}
		}
		
		// Return player 
		return player;
	}
	
	// Define functions to get cumulative stats for this team in each category
	public int getPassYds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players pass_yds to sum
			sum += off_players.get(i).getPass_yds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getPassTds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players pass_tds to sum
			sum += off_players.get(i).getPass_tds();
		}
		
		// Return sum
		return sum;		
	}
	
	public int getPicks(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players picks to sum
			sum += off_players.get(i).getPicks();
		}
		
		// Return sum
		return sum;	
	}
	
	public int getPass2pt(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players pass_2pt to sum
			sum += off_players.get(i).getPass_2pt();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRushYds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rush_yds to sum
			sum += off_players.get(i).getRush_yds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRushTds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rush_tds to sum
			sum += off_players.get(i).getRush_tds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRush2pt(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rush_2pt to sum
			sum += off_players.get(i).getRush_2pt();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRecYds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rec_yds to sum
			sum += off_players.get(i).getRec_yds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRecTds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rec_tds to sum
			sum += off_players.get(i).getRec_tds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRec2pt(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players rec_2pt to sum
			sum += off_players.get(i).getRec_2pt();
		}
		
		// Return sum
		return sum;
	}
	
	public int getFumbles(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players fumbles to sum
			sum += off_players.get(i).getFumbles();
		}
		
		// Return sum
		return sum;
	}
	
	public int getRetTds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Add this players ret_tds to sum
			sum += off_players.get(i).getRet_tds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getDefTds(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players def_tds to sum
			sum += def_players.get(i).getDef_tds();
		}
		
		// Return sum
		return sum;
	}
	
	public int getDefPicks(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players picks to sum
			sum += def_players.get(i).getPicks();
		}
		
		// Return sum
		return sum;		
	}
	
	public int getDefFumbles(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players fumbles to sum
			sum += def_players.get(i).getFumbles();
		}
		
		// Return sum
		return sum;
	}
	
	public int getSacks(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players sacks to sum
			sum += def_players.get(i).getSacks();
		}
		
		// Return sum
		return sum;
	}
	
	public int getBlocks(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players blocks to sum
			sum += def_players.get(i).getBlocks();
		}
		
		// Return sum
		return sum;
	}
	
	public int getSafeties(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players safeties to sum
			sum += def_players.get(i).getSafeties();
		}
		
		// Return sum
		return sum;
	}
	
	public int getPA(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players pa to sum
			sum += def_players.get(i).getPa();
		}
		
		// Return sum
		return sum;
	}
	
	public int getYA(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Add this players ya to sum
			sum += def_players.get(i).getYa();
		}
		
		// Return sum
		return sum;
	}
	
	public int getPAT(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Add this players pat to sum
			sum += kickers.get(i).getPat();
		}
		
		// Return sum
		return sum;
	}
	
	public int getFG0(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Add this players fg0 to sum
			sum += kickers.get(i).getFg0();
		}
		
		// Return sum
		return sum;
	}
	
	public int getFG1(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Add this players fg1 to sum
			sum += kickers.get(i).getFg1();
		}
		
		// Return sum
		return sum;
	}
	
	public int getFG2(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Add this players fg2 to sum
			sum += kickers.get(i).getFg2();
		}
		
		// Return sum
		return sum;
	}
	
	public int getMisses(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Add this players misses to sum
			sum += kickers.get(i).getMisses();
		}
		
		// Return sum
		return sum;
	}
	
	// Define a function to add this teams cumulative points
	public int calculatePoints(){
		// Initialize sum to 0
		int sum = 0;
		
		// Iterate through off_players array
		for(int i = 0; i < off_players.size(); i++){
			// Calculate points for this player and add that to sum
			sum += off_players.get(i).calculatePoints();
		}
		
		// Iterate through def_players array
		for(int i = 0; i < def_players.size(); i++){
			// Calculate points for this player and add that to sum
			sum += def_players.get(i).calculatePoints();
		}
		
		// Iterate through kickers array
		for(int i = 0; i < kickers.size(); i++){
			// Calculate points for this player and add that to sum
			sum += kickers.get(i).calculatePoints();
		}
		
		// Return sum
		return sum;
	}
	
	// Define a function to sort offensive players by different metrics
	public void sortOffPlayers(int type){
		// Check if type is 0
		if(type == 0){
			// If so sort by pass_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players pass_yds are less than the next players
					if(off_players.get(i).getPass_yds() < off_players.get(i+1).getPass_yds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 1
		else if(type == 1){
			// If so sort by pass_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players pass_tds are less than the next players
					if(off_players.get(i).getPass_tds() < off_players.get(i+1).getPass_tds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}			
		}
		
		// Else check if type is 2
		else if(type == 2){
			// If so sort by picks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players picks are more than the next players
					if(off_players.get(i).getPicks() > off_players.get(i+1).getPicks()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 3
		else if(type == 3){
			// If so sort by pass_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players pass_2pt are less than the next players
					if(off_players.get(i).getPass_2pt() < off_players.get(i+1).getPass_2pt()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 4
		else if(type == 4){
			// If so sort by rush_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rush_yds are less than the next players
					if(off_players.get(i).getRush_yds() < off_players.get(i+1).getRush_yds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 5
		else if(type == 5){
			// If so sort by rush_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rush_tds are less than the next players
					if(off_players.get(i).getRush_tds() < off_players.get(i+1).getRush_tds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 6
		else if(type == 6){
			// If so sort by rush_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rush_2pt are less than the next players
					if(off_players.get(i).getRush_2pt() < off_players.get(i+1).getRush_2pt()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 7
		else if(type == 7){
			// If so sort by rec_yds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rec_yds are less than the next players
					if(off_players.get(i).getRec_yds() < off_players.get(i+1).getRec_yds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 8
		else if(type == 8){
			// If so sort by rec_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rec_tds are less than the next players
					if(off_players.get(i).getRec_tds() < off_players.get(i+1).getRec_tds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 9
		else if(type == 9){
			// If so sort by rec_2pt
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players rec_2pt are less than the next players
					if(off_players.get(i).getRec_2pt() < off_players.get(i+1).getRec_2pt()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 10
		else if(type == 10){
			// If so sort by fumbles
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players fumbles are more than the next players
					if(off_players.get(i).getFumbles() > off_players.get(i+1).getFumbles()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 11
		else if(type == 11){
			// If so sort by ret_tds
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players ret_tds are less than the next players
					if(off_players.get(i).getRet_tds() < off_players.get(i+1).getRet_tds()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else type is 12
		else{
			// If so sort by points
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first off_player to second to last
				for(int i = 0; i < off_players.size(); i++){
					// Check if this players points are less than the next players
					if(off_players.get(i).calculatePoints() < off_players.get(i+1).calculatePoints()){
						// If so swap these players
						OffPlayer temp = off_players.get(i);
						off_players.set(i, off_players.get(i+1));
						off_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
	}
	
	// Define a function to sort defensive players by different metrics
	public void sortDefPlayers(int type){
		// Check if type is 0
		if(type == 0){
			// If so sort by def_tds
		
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players def_tds are less than the next players
					if(def_players.get(i).getDef_tds() < def_players.get(i+1).getDef_tds()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 1
		else if(type == 1){
			// If so sort by picks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players picks are less than the next players
					if(def_players.get(i).getPicks() < def_players.get(i+1).getPicks()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}			
		}
		
		// Else check if type is 2
		else if(type == 2){
			// If so sort by fumbles
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players fumbles are less than the next players
					if(def_players.get(i).getFumbles() < def_players.get(i+1).getFumbles()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 3
		else if(type == 3){
			// If so sort by sacks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players sacks are less than the next players
					if(def_players.get(i).getSacks() < def_players.get(i+1).getSacks()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 4
		else if(type == 4){
			// If so sort by blocks
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players blocks are less than the next players
					if(def_players.get(i).getBlocks() < def_players.get(i+1).getBlocks()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 5
		else if(type == 5){
			// If so sort by safeties
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players safeties are less than the next players
					if(def_players.get(i).getSafeties() < def_players.get(i+1).getSafeties()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 6
		else if(type == 6){
			// If so sort by pa
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players pa are more than the next players
					if(def_players.get(i).getPa() > def_players.get(i+1).getPa()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 7
		else if(type == 7){
			// If so sort by ya
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players ya are more than the next players
					if(def_players.get(i).getYa() > def_players.get(i+1).getYa()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else type is 8
		else{
			// If so sort by points
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate form first def_player to second to last one
				for(int i = 0; i < def_players.size() - 1; i++){
					// Check if this players points are less than the next players
					if(def_players.get(i).calculatePoints() < def_players.get(i+1).calculatePoints()){
						// If so swap these two players
						DefPlayer temp = def_players.get(i);
						def_players.set(i, def_players.get(i+1));
						def_players.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
	}
	
	// Define a function to sort kickers by different metrics
	public void sortKickers(int type){
		// Check if type is 0
		if(type == 0){
			// If so sort by pat
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers pat are less than the next ones
					if(kickers.get(i+1).getPat() < kickers.get(i+1).getPat()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 1
		else if(type == 1){
			// If so sort by fg0
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers fg0 are less than the next ones
					if(kickers.get(i+1).getFg0() < kickers.get(i+1).getFg0()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}			
		}
		
		// Else check if type is 2
		else if(type == 2){
			// If so sort by fg1
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers fg1 are less than the next ones
					if(kickers.get(i+1).getFg1() < kickers.get(i+1).getFg1()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 3
		else if(type == 3){
			// If so sort by fg2
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers fg2 are less than the next ones
					if(kickers.get(i+1).getFg2() < kickers.get(i+1).getFg2()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 4
		else if(type == 4){
			// If so sort by misses
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers misses are more than the next ones
					if(kickers.get(i+1).getMisses() > kickers.get(i+1).getMisses()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
		
		// Else check if type is 4
		else if(type == 4){
			// If so sort by points
			
			// Initialize done to false
			boolean done = false;
			
			// Iterate while not done
			while(!done){
				// Set done to true
				done = true;
				
				// Iterate from first kicker to second to last one
				for(int i = 0; i < kickers.size() - 1; i++){
					// Check if this kickers points are less than the next ones
					if(kickers.get(i+1).calculatePoints() < kickers.get(i+1).calculatePoints()){
						// If so swap these two kickers
						Kicker temp = kickers.get(i);
						kickers.set(i, kickers.get(i+1));
						kickers.set(i+1, temp);
						
						// Set done to false
						done = false;
					}
				}
			}
		}
	}
}
